package main

import (
	"errors"
	"fmt"
)

func colsure() func() int {
	i := 0
	return func() int {
		i++
		return i
	}
}

func sum(a, b int) (sum int, err error) {

	if a < 0 || b < 0 {

		return 0, errors.New("a或者b不能是负数")

	}

	sum = a + b

	err = nil

	return

}
func main() {
	result, err := sum(1, 2)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(result)
	}
	sum2 := func(a, b int) int {
		return a + b
	}
	fmt.Println(sum2(1, 2))
	c1 := colsure()
	fmt.Println(c1())
	fmt.Println(c1())
	fmt.Println(c1())
	age := Age(25)
	age.String()
	//age.Modify()
	age.String()
	(&age).Modify()
	age.String()
}

type Age uint

func (age Age) String() {
	fmt.Println("the age is", age)
}

func (age *Age) Modify() {
	*age = Age(30)
}
